<template>
	<view class="setting">
		<!-- 设置页面 start -->

		<!--  -->




		<!-- 功能区 -->
		  <view class="bottom">
			<!--     <text class="function_title">常用功能</text> -->
			<!--       <view class="function" bindtap="JumpTocollect"><text>我的收藏</text> -->
			<!-- <image style="width: 56rpx; height: 56rpx;" src=" /pages/images/enter-icon.png" /> -->
			<!-- </view> -->
			<!--       <view class="function" bindtap="JumpToKefu"><text>浏览记录</text> -->
			<!-- <image style="width: 56rpx; height: 56rpx;" src=" /pages/images/enter-icon.png" /> -->
			<!-- </view> -->
			    <text class="function_title">设置</text>
			<view class="function" @click="setBtn(6)">
				<text>修改简历</text>
				<image style="width: 40rpx; height: 40rpx;" mode="aspectFit" src="../../static/image/right.png" />
				</image>
			</view>
			<view class="function" @click="setBtn(7)">
				<text>修改登录密码</text>
				<image style="width: 40rpx; height: 40rpx;" mode="aspectFit" src="../../static/image/right.png" />
			</view>
			<view class="function" @click="setBtn(5)"><text>公告</text>
				<image style="width: 40rpx; height: 40rpx;" mode="aspectFit" src="../../static/image/right.png" />
			</view>
			<view class="function" @click="setBtn(3)"><text>关于我们</text>
				<image style="width: 40rpx; height: 40rpx;" mode="aspectFit" src="../../static/image/right.png" />
			</view>
			<view class="function" @click="setBtn(4)"><text>退出登录</text>
				<image style="width: 40rpx; height: 40rpx;" mode="aspectFit" src="../../static/image/right.png" />
			</view>
		</view>
		 


		<!-- 展示的弹框 -->
		<uni-popup ref="popup" type="bottom">
			<view class="setting-popup">
				<view class="setting-popup-title">{{num==3?'关于我们':num==7?'修改密码':'公告'}}</view>
				<view class="setting-popup-box">
					<view class="setting-text" v-if="num!=7">{{num==3? aboutList : announcementList}}</view>
					<view class="setting-password" v-if="num==7">
						<uni-forms :modelValue="formData">
							<uni-forms-item>
								<uni-easyinput type="text" v-model="formData.password" placeholder="请输入要修改的密码" />
							</uni-forms-item>
						</uni-forms>
						<button type="default" @click="editPassword">确定</button>
					</view>
				</view>
			</view>
		</uni-popup>
		<!-- 设置页面 end -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				aboutList: '',
				num: 3,
				announcementList: '',
				formData: {
					password: ''
				}
			}
		},
		methods: {
			setBtn(k) {
				this.num = k;
				
				if (k == 4) {//退出登录
					uni.clearStorageSync()
				}
				
				if(k == 6){//修改简历
					uni.navigateTo({
						url:'/pages/resume/resume?type=edit'
					})
					return
				}
				
				k != 7 && this.$store.dispatch('editRequestList', k)
				
				if (k == 3 || k == 5 || k == 7) {
					this.$refs.popup.open('center');

				}

			},
			//修改登录密码
			editPassword() {
				const params = {
					type: 7,
					openid: uni.getStorageSync('openid') || '',
					password: this.formData.password
				}
				this.$api('writeProject', params).then(res => {
					console.log(res)
					uni.showToast({
						title: res.result.message,
						icon: 'none'
					})
					this.$refs.popup.close()
				}).catch(msg => {
					console.log(msg)
					uni.showToast({
						title: msg.message,
						icon: 'none'
					})
					this.$refs.popup.close()
				})
			}
		},
		computed: {
			aboutRequest() {
				return this.$store.state.aboutMyList
			},
			announcementRequest() {
				return this.$store.state.announcementList
			},
			loginOut() {
				return this.$store.state.loginOut
			}
		},
		watch: {
			aboutRequest(val) {
				this.aboutList = val;
			},
			announcementRequest(val) {
				this.announcementList = val;
			},
			loginOut(val) {
				console.log('退出登录', val)
				if (val) {
					uni.reLaunch({
						url: '/pages/login/login'
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	page {
		height: 100%;
	}

	.bottom {
		display: flex;
		overflow: hidden;
		flex-direction: column;
		// margin-top: 100rpx;
		padding-left: 56rpx;
		width: 694rpx;
		height: 1090rpx;

		border-top-left-radius: 30rpx;
		border-top-right-radius: 30rpx;
	}

	.function_title {
		margin-top: 36rpx;
		margin-left: 10rpx;
		margin-bottom: 18rpx;
		width: 140rpx;
		height: 42rpx;
		color: rgba(193, 193, 193, 1);
		font-size: 32rpx;
	}

	.function {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 6rpx;
		padding-left: 32rpx;
		padding-right: 32rpx;
		width: 584rpx;
		height: 100rpx;
		background-color: #ffffff;
		border-radius: 10rpx;
	}

	/*
	.function{
	  position: fixed;
	  bottom:10rpx;
	  display: flex;
	  flex-direction: row;
	}
	
	.function-item{
	  margin: 40rpx;
	  display: flex;
	  flex-direction: column;
	  align-items: center;
	}*/

	.function-icon {
		width: 48rpx;
		height: 48rpx;
	}

	.setting {
		width: 100%;
		height: 100%;
		background-color: rgba(245, 247, 249, 1);

		.setting-popup {
			width: 600upx;
			margin: 0 auto;
			box-sizing: border-box;
			padding: 40upx;
			background-color: #fff;
			border-radius: 20upx;

			.setting-popup-title {
				width: 100%;
				padding-bottom: 20upx;
				text-align: center;
				font-size: 30upx;
				font-weight: bold;
				border-bottom: 1upx solid #c6c6c6;
			}

			.setting-popup-box {
				padding-top: 20upx;
			}

			.setting-text {
				text-indent: 2em;
				font-size: 28upx;

			}
		}
	}
</style>
